home *** CD-ROM | disk | FTP | other *** search
/ PCMania 34 / PCMania CD34.iso / anima / anima4 / source / poling.c
Encoding:
C/C++ Source or Header  |  1995-04-06  |  52.3 KB  |  2,221 lines

  1. #define True 1
  2. #define False 0
  3. #include <fcntl.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <conio.h>
  9. #include <unistd.h>
  10. #include <math.h>
  11.  
  12.     /* Declaracion de funciones globales */
  13.  
  14.     void ChoseFont(char *);
  15.     void PutsFont(char);
  16.     void SetScale(void);
  17.     void ScaleTexture(char);
  18.     void SetTexture(void);
  19.     void SetRotate(void);
  20.     void PutsRotate(void);
  21.     void PutsDescription(void);
  22.     void PutsTranslate(void);
  23.     void SetTranslate(void);
  24.     void SetFrames(void);
  25.     void PutsTranslateLineal(void);
  26.     void SetAmbiente(void);
  27.     void PutsStartUnion(void);
  28.     void PutsEndObject(void);
  29.     void PutsDefCamera(void);
  30.  
  31.     /* Debido a la gran cantidad de variables existentes intercambiables */
  32.     /* entre las distintas funciones y dada la simpleza del programa se  */
  33.     /* han declarado todas las variables globales.                       */
  34.  
  35.      char Buffer[255], ObjectName[255], IncludeFile[255], Select, Texture;
  36.      double x, y, angle, LongIdeal, Separacion, TotalAngle, StartAngle;
  37.      double Scale, CamPos, Zoom, Radio, RadioF, w, LongPag, CamIdeal = -100.0;
  38.      char rotado, letra, Operacion;
  39.      int pointer, cont, Long1, Long2, Lineas, ContLineas;
  40.      FILE *Temp, *out;
  41.      char font1, font2, Color[255], FileName[255];
  42.      char TextoI[255] = "", TextoS[255] = "";
  43.      double CamOffset, ZoomOffset;
  44.      int Frames, ContFrames;
  45.      double StartAngle, AngleOffset, Rx, Ry, Rz, RxOffset, RyOffset, RzOffset;
  46.      char Fx[255], Fy[255], Fz[255], Aspect[10];
  47.      double Tx, Ty, Tz, TxOffset, TyOffset, TzOffset;
  48.      unsigned sFx, sFy, sFz, sColor, sTextoS;
  49.      double ScaleF = 1.2;
  50.      char fontF = '1', Ambiente, TextName[255];
  51.      char IncludeName[255], Color2[255], Texture2, Select2;
  52.      double CamOffsetX, CamOffsetY, CamX, CamY;
  53.      double Rix, Riy, Riz, RiOffsetX, RiOffsetY, RiOffsetZ;
  54.      int ContText, NumText, YetMulti = False, YetFont = False;
  55.      double Z, EndZ;
  56.      char RayT, ext[4];
  57.  
  58. int main(void)
  59. {
  60.      int  Menu(void);
  61.      void PonerAmbiente(void);
  62.      void DosLineas(void);
  63.      void DosLineasY(void);
  64.      void LineaCircular(void);
  65.      void LineasTexto(void);
  66.  
  67.      int ErrorLevel;
  68.  
  69.      /* Abrimos un fichero donde contener los datos (circulo.pov) */
  70.  
  71.      puts("");
  72.      highvideo();
  73.      cprintf("Rotate Fonts & Objects for POV & Poly Ray ver. 1.1");
  74.      lowvideo();
  75.      puts("");
  76.  
  77.      /* Presentamos el Menu */
  78.  
  79.      ErrorLevel = Menu();
  80.  
  81.      if (ErrorLevel != 0)
  82.         return ErrorLevel;
  83.  
  84.      /* Ponemos una camara y dos luces */
  85.  
  86.      if (Ambiente == '4')
  87.         strcpy(ext, "inc");
  88.      else
  89.      {
  90.         if (RayT == '1')
  91.             strcpy(ext, "pov");
  92.         else
  93.             strcpy(ext, "pi");
  94.      }
  95.  
  96.      if (Frames == 1 || (RayT == '2') )
  97.      {
  98.         printf ("\nIntroduce el nombre del fichero de salida [circulo.%s] : ", ext);
  99.         gets(Buffer);
  100.  
  101.         if (Buffer[0])
  102.             strcpy(FileName, Buffer);
  103.         else
  104.             sprintf(FileName, "circulo.%s", ext);
  105.  
  106.         _fmode = O_TEXT;
  107.         if ((out = fopen(FileName, "w+"))  == NULL)
  108.         {
  109.             printf("Error no puedo abrir el fichero de salida.\n");
  110.             return 1;
  111.         }
  112.  
  113.         /* Comienzan los calculos */
  114.  
  115.         switch (Operacion) {
  116.                     case '1':
  117.  
  118.                     case '2': {
  119.                                 PutsDescription();
  120.                                 PutsTranslate();
  121.                                 PonerAmbiente();
  122.                                 DosLineas();
  123.                     } break;
  124.  
  125.                     case 'Y': {
  126.                                 PutsDescription();
  127.                                 PutsTranslate();
  128.                                 PonerAmbiente();
  129.                                 DosLineasY();
  130.                     } break;
  131.  
  132.                     case 'E':
  133.  
  134.                     case 'C': {
  135.                                 PutsDescription();
  136.                                 PutsTranslate();
  137.                                 PonerAmbiente();
  138.                                 LineaCircular();
  139.                     } break;
  140.  
  141.                     case 'L': {
  142.                                 PutsDescription();
  143.                                 LineasTexto();
  144.                     } break;
  145.         }
  146.         fclose(out);
  147.  
  148.         /* Mensajillo de exito */
  149.  
  150.         printf("\nFichero generado ---> %s", FileName);
  151.      }
  152.      else
  153.      {
  154.      if ( Frames > 1)
  155.      {
  156.             printf("\n");
  157.             for (ContFrames = 1; ContFrames <= Frames; ContFrames++)
  158.             {
  159.                 sprintf(FileName, "frame%d.pov", ContFrames);
  160.  
  161.                 _fmode = O_TEXT;
  162.                 if ((out = fopen(FileName, "w+"))  == NULL)
  163.                 {
  164.                     printf("Error no puedo abrir el fichero de salida.\n");
  165.                     return 1;
  166.                 }
  167.  
  168.                 /* Comienzan los calculos */
  169.  
  170.                 switch (Operacion) {
  171.  
  172.                     case '1':
  173.  
  174.                     case '2': {
  175.                                 PutsDescription();
  176.                                 PutsTranslate();
  177.                                 PonerAmbiente();
  178.                                 DosLineas();
  179.                     } break;
  180.  
  181.                     case 'Y': {
  182.                                 PutsDescription();
  183.                                 PutsTranslate();
  184.                                 PonerAmbiente();
  185.                                 DosLineasY();
  186.                     } break;
  187.  
  188.                     case 'E':
  189.  
  190.                     case 'C': {
  191.                                 PutsDescription();
  192.                                 PutsTranslate();
  193.                                 PonerAmbiente();
  194.                                 LineaCircular();
  195.                     } break;
  196.  
  197.                     case 'L': {
  198.                                 PutsDescription();
  199.                                 LineasTexto();
  200.                     } break;
  201.  
  202.                 }
  203.  
  204.                 printf("Generado fichero --> %s", FileName);
  205.                 gotoxy(1, wherey());
  206.  
  207.                 if (RayT == '1')
  208.                 {
  209.                     CamX += CamOffsetX;   /* Simples acercamientos de camará */
  210.                     CamY += CamOffsetY;
  211.                     CamPos += CamOffset;
  212.                     Zoom += ZoomOffset;
  213.  
  214.                     Rx += RxOffset;      /* Rotaciones de un objeto */
  215.                     Ry += RyOffset;
  216.                     Rz += RzOffset;
  217.  
  218.                     Rix += RiOffsetX;      /* Rotaciones de un objeto */
  219.                     Riy += RiOffsetY;
  220.                     Riz += RiOffsetZ;
  221.                 }
  222.  
  223.                 fclose(out);
  224.             }
  225.      } /* Fin del if */
  226.      } /* fin del else */
  227.  
  228.      printf("\n\n");
  229.  
  230.      if (Operacion == 'L') /* Borramos los temporales */
  231.      {
  232.         fclose(Temp);
  233.         unlink("Temp.$$$");
  234.      }
  235.  
  236.      return 0;
  237. }
  238.  
  239. int Menu(void)
  240. {
  241.     int font_x;
  242.     unsigned ObjectSize;
  243.  
  244.     /* Opciones del modo de operacion */
  245.  
  246.     printf("\n (1) Un circulo vertical\n (2) Dos semicirculos verticales\n (Y) Dos semicirculos horizontales\n (C) Una linea en circulo\n (E) Una linea en espiral\n (L) Fonts lineales");
  247.     printf("\n\nEligue orientacion: (1/2/Y/C/E/L) [C]: ");
  248.     Operacion = toupper(getc(stdin));
  249.  
  250.     if (Operacion == '\n')
  251.         Operacion = 'C';
  252.     else
  253.         getc(stdin);
  254.  
  255.     printf("\n (1) Pov-Ray ver 2.x\n (2) PolyRay ver 1.7");
  256.     printf("\n\nEligue raytracer: (1/2) [2]: ");
  257.     RayT = getc(stdin);
  258.  
  259.     if (RayT == '\n')
  260.         RayT = '2';
  261.     else
  262.         getc(stdin);
  263.  
  264.     /* Opciones especificas de cada modo de operacion */
  265.  
  266.     switch (Operacion) {
  267.                     case '1':
  268.  
  269.                     case 'Y':
  270.  
  271.                     case '2': {
  272.  
  273.                                 /* Peticion de datos importantes */
  274.  
  275.                                 printf ("Introduce el texto a circular por arriba [Hello] : ");
  276.                                 gets(Buffer);
  277.  
  278.                                 if (Buffer[0])
  279.                                     strcpy(TextoS, Buffer);
  280.                                 else
  281.                                     strcpy(TextoS, "Hello");
  282.  
  283.                                 ChoseFont(&font1);
  284.  
  285.                                 if (Operacion == '2' || Operacion == 'Y')
  286.                                 {
  287.                                     printf ("Introduce el texto a circular por abajo [World] : ");
  288.                                     gets(Buffer);
  289.  
  290.                                     if (Buffer[0])
  291.                                         strcpy(TextoI, Buffer);
  292.                                     else
  293.                                         strcpy(TextoI, "World");
  294.  
  295.                                     ChoseFont(&font2);
  296.                                 }
  297.  
  298.                                 SetScale();
  299.  
  300.                                 printf("Introduce el radio [20] : ");
  301.                                 gets(Buffer);
  302.  
  303.                                 if (Buffer[0])
  304.                                     Radio = atof(Buffer);
  305.                                 else
  306.                                     Radio = 20;
  307.  
  308.                                 SetFrames();
  309.                                 SetTexture();
  310.                                 SetRotate();
  311.                                 SetTranslate();
  312.                     } break;
  313.  
  314.                     case 'E':
  315.  
  316.                     case 'C': {
  317.                                 /* Peticion de datos importantes */
  318.  
  319.                                 printf ("Introduce el texto a circular [Hello World] : ");
  320.                                 gets(Buffer);
  321.  
  322.                                 if (Buffer[0])
  323.                                     strcpy(TextoS, Buffer);
  324.                                 else
  325.                                     strcpy(TextoS, "Hello World");
  326.  
  327.                                 ChoseFont(&font1);
  328.  
  329.                                 if (Operacion == 'E')
  330.                                 {
  331.                                     printf("Introduce el radio Inicial [20] : ");
  332.                                     gets(Buffer);
  333.  
  334.                                     if (Buffer[0])
  335.                                         Radio = atof(Buffer);
  336.                                     else
  337.                                         Radio = 20;
  338.  
  339.                                     printf("Introduce el radio Final [30] : ");
  340.                                     gets(Buffer);
  341.  
  342.                                     if (Buffer[0])
  343.                                         RadioF = atof(Buffer);
  344.                                     else
  345.                                         RadioF = 30;
  346.  
  347.                                     printf("Introduce la Z Inicial [-5] : ");
  348.                                     gets(Buffer);
  349.  
  350.                                     if (Buffer[0])
  351.                                         Z = atof(Buffer);
  352.                                     else
  353.                                         Z = -5;
  354.  
  355.                                     printf("Introduce la Z Final [10] : ");
  356.                                     gets(Buffer);
  357.  
  358.                                     if (Buffer[0])
  359.                                         EndZ = atof(Buffer);
  360.                                     else
  361.                                         EndZ = 10;
  362.                                 }
  363.                                 else
  364.                                 {
  365.                                     printf("Introduce el radio [20] : ");
  366.                                     gets(Buffer);
  367.  
  368.                                     if (Buffer[0])
  369.                                         Radio = atof(Buffer);
  370.                                     else
  371.                                         Radio = 20;
  372.                                 }
  373.  
  374.                                 SetScale();
  375.  
  376.                                 printf ("Introduce el angulo total de recorrido [315] : ");
  377.                                 gets(Buffer);
  378.  
  379.                                 if (Buffer[0])
  380.                                     TotalAngle = atof(Buffer);
  381.                                 else
  382.                                     TotalAngle = 315;
  383.  
  384.                                 printf ("Introduce el angulo de comienzo [225] : ");
  385.                                 gets(Buffer);
  386.  
  387.                                 if (Buffer[0])
  388.                                     StartAngle = atof(Buffer);
  389.                                 else
  390.                                     StartAngle = 225;
  391.  
  392.                                 SetFrames();
  393.                                 SetTexture();
  394.                                 SetRotate();
  395.                                 SetTranslate();
  396.                     } break;
  397.  
  398.                     case 'L': {
  399.  
  400.                                 /* Habilitamos un fichero temporal para guardar */
  401.                                 /* las distintas lineas de texto.               */
  402.  
  403.                                 _fmode = O_BINARY;
  404.                                 if ((Temp = fopen("temp.$$$", "w+"))  == NULL)
  405.                                 {
  406.                                     printf("Error no puedo abrir el fichero temporal.\n");
  407.                                     return 2;
  408.                                 }
  409.  
  410.                                 /* Peticion de datos importantes */
  411.  
  412.                                 printf ("Cuantas lineas de texto quieres introducir [1] : ");
  413.                                 gets(Buffer);
  414.  
  415.                                 if (Buffer[0])
  416.                                     Lineas = atoi(Buffer);
  417.                                 else
  418.                                     Lineas = 1;
  419.  
  420.                                 SetFrames();
  421.  
  422.                                 for (ContLineas = 1; ContLineas <= Lineas; ContLineas ++)
  423.                                 {
  424.                                     printf ("\nIntroduce la linea de texto%d [Linea %d] : ", ContLineas, ContLineas);
  425.                                     gets(Buffer);
  426.  
  427.                                     if (Buffer[0])
  428.                                         strcpy(TextoS, Buffer);
  429.                                     else
  430.                                         sprintf(TextoS, "Linea %d", ContLineas);
  431.  
  432.  
  433.                                     ChoseFont(&font1);
  434.  
  435.                                     if (font1 == '2') /* Estratagema */
  436.                                         font2 = '2';
  437.  
  438.                                     SetScale();
  439.  
  440.                                     printf("Pixels de separacion entre letras [2]: ");
  441.                                     gets(Buffer);
  442.  
  443.                                     if (Buffer[0])
  444.                                         Separacion = atof(Buffer);
  445.                                     else
  446.                                         Separacion = 2;
  447.  
  448.                                     if (font1 == '1')
  449.                                         font_x = 5;
  450.                                     else
  451.                                         font_x = 8;
  452.  
  453.                                     SetTexture();
  454.                                     SetRotate();
  455.                                     SetTranslate();
  456.  
  457.                                     /* Swappeada al Temporal en binario */
  458.  
  459.                                     ObjectSize = strlen(ObjectName)+1;
  460.  
  461.                                     fwrite(&ObjectSize, sizeof(unsigned), 1, Temp);
  462.                                     fwrite(ObjectName, ObjectSize, 1, Temp);
  463.  
  464.                                     fwrite(&Rx, sizeof(Rx), 1, Temp);
  465.                                     fwrite(&Ry, sizeof(Ry), 1, Temp);
  466.                                     fwrite(&Rz, sizeof(Rz), 1, Temp);
  467.  
  468.                                     fwrite(&Tx, sizeof(Tx), 1, Temp);
  469.                                     fwrite(&Ty, sizeof(Ty), 1, Temp);
  470.                                     fwrite(&Tz, sizeof(Tz), 1, Temp);
  471.  
  472.                                     fwrite(&Rix, sizeof(double), 1, Temp);
  473.                                     fwrite(&Riy, sizeof(double), 1, Temp);
  474.                                     fwrite(&Riz, sizeof(double), 1, Temp);
  475.  
  476.                                     fwrite(&RxOffset, sizeof(RxOffset), 1, Temp);
  477.                                     fwrite(&RyOffset, sizeof(RyOffset), 1, Temp);
  478.                                     fwrite(&RzOffset, sizeof(RzOffset), 1, Temp);
  479.  
  480.                                     fwrite(&TxOffset, sizeof(TxOffset), 1, Temp);
  481.                                     fwrite(&TyOffset, sizeof(TyOffset), 1, Temp);
  482.                                     fwrite(&TzOffset, sizeof(TzOffset), 1, Temp);
  483.  
  484.                                     fwrite(&RiOffsetX, sizeof(double), 1, Temp);
  485.                                     fwrite(&RiOffsetY, sizeof(double), 1, Temp);
  486.                                     fwrite(&RiOffsetZ, sizeof(double), 1, Temp);
  487.  
  488.                                     sFx = strlen(Fx)+1;
  489.                                     sFy = strlen(Fy)+1;
  490.                                     sFz = strlen(Fz)+1;
  491.  
  492.                                     fwrite(&sFx, sizeof(sFx), 1, Temp);
  493.                                     fwrite(&sFy, sizeof(sFy), 1, Temp);
  494.                                     fwrite(&sFz, sizeof(sFz), 1, Temp);
  495.  
  496.                                     fwrite(Fx, sFx, 1, Temp);
  497.                                     fwrite(Fy, sFy, 1, Temp);
  498.                                     fwrite(Fz, sFz, 1, Temp);
  499.  
  500.                                     LongPag = (font_x + Separacion) * Scale * strlen(TextoS);
  501.  
  502.                                     fwrite(&Texture, sizeof(char), 1, Temp);
  503.                                     fwrite(&Select, sizeof(char), 1, Temp);
  504.  
  505.                                     sColor = strlen(Color)+1;
  506.                                     fwrite(&sColor, sizeof(unsigned), 1, Temp);
  507.                                     fwrite(Color, sColor, 1, Temp);
  508.  
  509.                                     fwrite(&font1, sizeof(char), 1, Temp);
  510.  
  511.                                     sTextoS = strlen(TextoS)+1;
  512.                                     fwrite(&sTextoS, sizeof(unsigned), 1, Temp);
  513.                                     fwrite(TextoS, sTextoS, 1, Temp);
  514.  
  515.                                     fwrite(&Scale, sizeof(Scale), 1, Temp);
  516.                                     fwrite(&LongPag, sizeof(LongPag), 1, Temp);
  517.                                  }
  518.                             } break;
  519.     }
  520.  
  521.     /* Opciones generales */
  522.  
  523.     SetAmbiente();
  524.  
  525.     if (Ambiente != '4')
  526.     {
  527.         printf ("Posicion horizontal de la camara [0]: ");
  528.         gets(Buffer);
  529.  
  530.         if (Buffer[0])
  531.             CamX = atof(Buffer);
  532.         else
  533.             CamX = 0;
  534.  
  535.         printf ("Posicion vertical la camara [0]: ");
  536.         gets(Buffer);
  537.  
  538.         if (Buffer[0])
  539.             CamY = atof(Buffer);
  540.         else
  541.             CamY = 0;
  542.  
  543.         printf ("Lejanía de la camara [%d]: ", (int) CamIdeal);
  544.         gets(Buffer);
  545.  
  546.         if (Buffer[0])
  547.             CamPos = atof(Buffer);
  548.         else
  549.             CamPos = CamIdeal;
  550.  
  551.         printf ("Factor de zoom: [1] : ");
  552.         gets(Buffer);
  553.  
  554.         if (Buffer[0])
  555.             Zoom = atof(Buffer);
  556.         else
  557.             Zoom = 1;
  558.  
  559.         if (Frames > 1)
  560.         {
  561.  
  562.             printf ("Desplazamiento horizontal de la camara [0]: ");
  563.             gets(Buffer);
  564.  
  565.             if (Buffer[0])
  566.                 CamOffsetX = atof(Buffer);
  567.             else
  568.                 CamOffsetX = 0;
  569.  
  570.             printf ("Desplazamiento vertical de la camara [0]: ");
  571.             gets(Buffer);
  572.  
  573.             if (Buffer[0])
  574.                 CamOffsetY = atof(Buffer);
  575.             else
  576.                 CamOffsetY = 0;
  577.  
  578.             printf ("Acercamiento de la camara [0]: ", CamOffset);
  579.             gets(Buffer);
  580.  
  581.             if (Buffer[0])
  582.                 CamOffset = atof(Buffer);
  583.             else
  584.                 CamOffset = 0;
  585.  
  586.             printf ("Incremento del factor de zoom [0] : ");
  587.             gets(Buffer);
  588.  
  589.             if (Buffer[0])
  590.                 ZoomOffset = atof(Buffer);
  591.             else
  592.                 ZoomOffset = 0;
  593.         }
  594.  
  595.         if (Frames > 1)
  596.             strcpy(Aspect, "1.6");
  597.         else
  598.             strcpy(Aspect, "4/3");
  599.  
  600.         printf ("Aspect Ratio (320 x 200 = 1.6, 640 x 480 = 4 / 3) [%s]: ", Aspect);
  601.         gets(Buffer);
  602.  
  603.         if (Buffer[0])
  604.             strcpy(Aspect, Buffer);
  605.     }
  606.  
  607.     Long1 = strlen(TextoS);
  608.     Long2 = strlen(TextoI);
  609.  
  610.     return 0;
  611. }
  612.  
  613. void PonerAmbiente(void)
  614. {
  615.      /* Ponemos los distintos includes */
  616.  
  617.      if (Ambiente != '4')
  618.      {
  619.         if (RayT == '1')
  620.         {
  621.             fprintf(out, "#include \"colors.inc\"\n");
  622.             fprintf(out, "#include \"textures.inc\"\n");
  623.             fprintf(out, "#include \"stones.inc\"\n");
  624.         }
  625.         else
  626.         {
  627.             fprintf(out, "include \"dat\\colors.inc\"\n");
  628.             fprintf(out, "include \"dat\\texture.inc\"\n");
  629.  
  630.             if (Frames > 1)
  631.             {
  632.                 fprintf(out, "start_frame 0\n");
  633.                 fprintf(out, "end_frame %d\n\n", Frames-1);
  634.             }
  635.         }
  636.  
  637.         if ( font1 == '1' || font2 == '1')
  638.             if (RayT == '1')
  639.                 fprintf(out, "#include \"chars.inc\"\n\n");
  640.  
  641.         if ( font1 == '2' || font2 == '2')
  642.             if (RayT == '1')
  643.                 fprintf(out, "#include \"fntrnd.inc\"\n\n");
  644.  
  645.         if ( font1 == '3' || font2 == '3' || RayT == '2' || YetFont == True)
  646.             if (RayT == '1')
  647.                 fprintf(out, "#include \"%s\"\n\n", IncludeFile);
  648.             else
  649.                 fprintf(out, "include \"%s\"\n\n", IncludeFile);
  650.  
  651.         if (Texture == '2' || YetMulti == True)
  652.             if (RayT == '1')
  653.                 fprintf(out, "#include \"%s\"\n\n", TextName);
  654.             else
  655.                 fprintf(out, "include \"%s\"\n\n", TextName);
  656.  
  657.         switch (Ambiente) {
  658.  
  659.                 case '1': {
  660.  
  661.                     if (RayT == '1')
  662.                         fprintf(out, "#include \"%s\"\n\n", IncludeName);
  663.                     else
  664.                         fprintf(out, "include \"%s\"\n\n", IncludeName);
  665.  
  666.                     PutsDefCamera();
  667.  
  668.                 } break;
  669.  
  670.                 case '2': {
  671.  
  672.                     if (RayT == '1')
  673.                     {
  674.                         fprintf(out, "#declare PosCamX = %f\n", CamX);
  675.                         fprintf(out, "#declare PosCamY = %f\n", CamY);
  676.                         fprintf(out, "#declare PosCamZ = %f\n", CamPos);
  677.                         fprintf(out, "#declare Zoom = %f\n\n", Zoom);
  678.  
  679.                         fprintf(out, "#include \"%s\"\n\n", IncludeName);
  680.                     }
  681.                     else
  682.                     {
  683.                         fprintf(out, "define PosCamX %f+(frame*%f) \n", CamX, CamOffsetX);
  684.                         fprintf(out, "define PosCamY %f+(frame*%f) \n", CamY, CamOffsetY);
  685.                         fprintf(out, "define PosCamZ %f+(frame*%f) \n", CamPos, CamOffset);
  686.                         fprintf(out, "define Zoom %f+(frame*%f) \n\n", Zoom, ZoomOffset);
  687.  
  688.                         fprintf(out, "include \"%s\"\n\n", IncludeName);
  689.                     }
  690.  
  691.                 } break;
  692.  
  693.                 case '3': {
  694.  
  695.                     if (RayT == '1')
  696.                     {
  697.                         fprintf(out, "#declare PosCamX = %f\n", CamX);
  698.                         fprintf(out, "#declare PosCamY = %f\n", CamY);
  699.                         fprintf(out, "#declare PosCamZ = %f\n", CamPos);
  700.                         fprintf(out, "#declare Zoom = %f\n\n", Zoom);
  701.                     }
  702.                     else
  703.                     {
  704.                         fprintf(out, "define PosCamX %f+(frame*%f) \n", CamX, CamOffsetX);
  705.                         fprintf(out, "define PosCamY %f+(frame*%f) \n", CamY, CamOffsetY);
  706.                         fprintf(out, "define PosCamZ %f+(frame*%f) \n", CamPos, CamOffset);
  707.                         fprintf(out, "define Zoom %f+(frame*%f) \n\n", Zoom, ZoomOffset);
  708.                     }
  709.  
  710.                     PutsDefCamera();
  711.  
  712.                 } break;
  713.  
  714.         } /* Fin del Switch */
  715.     } /* End del If */
  716. }
  717.  
  718. void DosLineas(void)
  719. {
  720.     /* Texto 1 */
  721.  
  722.     ContText=0;
  723.     pointer=0;
  724.     PutsStartUnion();
  725.     fprintf(out, " // Texto superior: %s\n\n", TextoS);
  726.     for (cont = 0; cont < Long1; cont ++ )
  727.     {
  728.         if ( TextoS[pointer] != ' ' )
  729.         {
  730.             letra = TextoS[pointer];
  731.             fprintf(out, "       object {\n");
  732.  
  733.             PutsFont(font1);
  734.  
  735.             if (Operacion == '2')
  736.                 angle = cont*(M_PI/Long1);
  737.             else
  738.                 angle = cont*((2*M_PI)/Long1);
  739.  
  740.             x = Radio * cos(M_PI - angle);
  741.             y = Radio * sin(angle);
  742.  
  743.             if (RayT == '2')
  744.             {
  745.                 fprintf(out, "               rotate <Rix, Riy, Riz>\n");
  746.                 fprintf(out, "               translate <%f, %f, -1.1>\n", x, y);
  747.             }
  748.             else
  749.             {
  750.                 fprintf(out, "               rotate <%f, %f, %f>\n", Rix, Riy, Riz);
  751.                 fprintf(out, "               translate <%f, %f, -1.1>\n", x, y);
  752.             }
  753.  
  754.             ScaleTexture('1');
  755.  
  756.             fprintf(out, "       }\n\n");
  757.             if (cont < (Long1-1))
  758.                 PutsEndObject();
  759.  
  760.         }
  761.         pointer++;
  762.         ContText++;
  763.     }
  764.  
  765.     ScaleTexture('2');
  766.     PutsRotate();
  767.     fprintf(out, " }// Fin de la union del texto superior.\n");
  768.  
  769.     /* Texto 2*/
  770.  
  771.     ContText=0;
  772.     if (Operacion == '2')
  773.     {
  774.         pointer=Long2 - 1;
  775.         PutsStartUnion();
  776.         fprintf(out, " // Texto inferior: %s\n\n", TextoI);
  777.         for (cont = 0; cont < Long2; cont ++ )
  778.         {
  779.             if ( TextoI[pointer] != ' ' )
  780.             {
  781.                 letra = TextoI[pointer];
  782.                 fprintf(out, "       object {\n");
  783.  
  784.                 PutsFont(font2);
  785.  
  786.                 angle = cont*(M_PI/Long2);
  787.                 x = Radio * cos(-angle);
  788.                 y = Radio * sin(-angle);
  789.  
  790.                 if (RayT == '2')
  791.                 {
  792.                     fprintf(out, "               rotate <Rix, Riy, Riz>\n");
  793.                     fprintf(out, "               translate <%f, %f, -1.1>\n", x, y);
  794.                 }
  795.                 else
  796.                 {
  797.                     fprintf(out, "               rotate <%f, %f, %f>\n", Rix, Riy, Riz);
  798.                     fprintf(out, "               translate <%f, %f, -1.1>\n", x, y);
  799.                 }
  800.  
  801.                 if (Select2 == '1' && RayT == '1')
  802.                 {
  803.                     fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  804.  
  805.                     if (Texture2 == '1')
  806.                         fprintf(out, "               texture { %s }\n", Color2);
  807.                     else
  808.                         fprintf(out, "               pigment { %s }\n", Color2);
  809.                 }
  810.                 else
  811.                 {
  812.                     if (Select2 == '1' && RayT == '2')
  813.                     {
  814.                     fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  815.                     fprintf(out, "               %s\n", Color2);
  816.                     }
  817.                 }
  818.  
  819.                 fprintf(out, "       }\n\n");
  820.  
  821.                 if (cont < (Long2-1))
  822.                     PutsEndObject();
  823.             }
  824.             pointer--;
  825.             ContText++;
  826.         }
  827.  
  828.         if (Select2 == '1' && RayT == '1')
  829.         {
  830.             fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  831.  
  832.             if (Texture2 == '1')
  833.                 fprintf(out, "               texture { %s }\n", Color2);
  834.             else
  835.                 fprintf(out, "               pigment { %s }\n", Color2);
  836.         }
  837.         else
  838.         {
  839.             if (Select2 == '1' && RayT == '2')
  840.             {
  841.                 fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  842.                 fprintf(out, "               %s\n", Color2);
  843.             }
  844.         }
  845.  
  846.         PutsRotate();
  847.         fprintf(out, "} // Fin de la union del texto inferior.\n");
  848.     } /* Fin del if Lineas */
  849. }
  850.  
  851. void DosLineasY(void)
  852. {
  853.     /* Texto 1 */
  854.  
  855.     ContText=0;
  856.     pointer=Long1 - 1;
  857.     PutsStartUnion();
  858.     fprintf(out, " // Texto superior: %s\n\n", TextoS);
  859.     for (cont = 0; cont < Long1; cont ++ )
  860.     {
  861.         if ( TextoS[pointer] != ' ' )
  862.         {
  863.             letra = TextoS[pointer];
  864.             fprintf(out, "       object {\n");
  865.  
  866.             PutsFont(font1);
  867.  
  868.             angle = cont*(M_PI/Long1);
  869.  
  870.             x = Radio * cos(- angle);
  871.             y = Radio * sin(- angle);
  872.  
  873.             if ( RayT == '1')
  874.             {
  875.                 fprintf(out, "               rotate <%f, ", Rix);
  876.                 fprintf(out, "%f, %f>\n", (double) - 90 + (angle*180/M_PI) + Riy, Riz);
  877.                 fprintf(out, "               translate <%f, 0, %f>\n", x, y);
  878.             }
  879.             else
  880.             {
  881.                 fprintf(out, "               rotate <Rix, ");
  882.                 fprintf(out, "Riy + %f, Riz>\n", (double) - 90 + (angle*180/M_PI));
  883.                 fprintf(out, "               translate <%f, 0, %f>\n", x, y);
  884.             }
  885.  
  886.             ScaleTexture('1');
  887.             fprintf(out, "       }\n\n");
  888.  
  889.             if (cont < (Long1-1))
  890.                 PutsEndObject();
  891.         }
  892.         pointer--;
  893.         ContText++;
  894.     }
  895.  
  896.     ScaleTexture('2');
  897.     PutsRotate();
  898.     fprintf(out, " } // Fin de la union del texto superior.\n");
  899.  
  900.     /* Texto 2*/
  901.  
  902.     ContText=0;
  903.     pointer=Long2 - 1;
  904.     PutsStartUnion();
  905.     fprintf(out, " // Texto inferior: %s\n\n", TextoI);
  906.     for (cont = 0; cont < Long2; cont ++ )
  907.     {
  908.         if ( TextoI[pointer] != ' ' )
  909.         {
  910.             letra = TextoI[pointer];
  911.             fprintf(out, "       object {\n");
  912.  
  913.             PutsFont(font2);
  914.  
  915.             angle = cont*(M_PI/Long2);
  916.             x = Radio * cos(M_PI - angle);
  917.             y = Radio * sin(angle);
  918.  
  919.             if ( RayT == '1')
  920.             {
  921.                 fprintf(out, "               rotate <%f, ", Rix);
  922.                 fprintf(out, "%f, %f>\n", (double) 90 + (angle*180/M_PI) + Riy, Riz);
  923.                 fprintf(out, "               translate <%f, 0, %f>\n", x, y);
  924.             }
  925.             else
  926.             {
  927.                 fprintf(out, "               rotate <Rix, ");
  928.                 fprintf(out, "Riy+%f, Riz>\n", (double) 90 + (angle*180/M_PI));
  929.                 fprintf(out, "               translate <%f, 0, %f>\n", x, y);
  930.             }
  931.  
  932.             if (Select2 == '1' && RayT == '1')
  933.             {
  934.                 fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  935.  
  936.                 if (Texture2 == '1')
  937.                     fprintf(out, "               texture { %s }\n", Color2);
  938.                 else
  939.                     fprintf(out, "               pigment { %s }\n", Color2);
  940.             }
  941.             else
  942.             {
  943.                 if (Select2 == '1' && RayT == '2')
  944.                 {
  945.                     fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  946.                     fprintf(out, "               %s\n", Color2);
  947.                 }
  948.             }
  949.  
  950.             fprintf(out, "       }\n\n");
  951.  
  952.             if (cont < (Long2-1))
  953.                 PutsEndObject();
  954.         }
  955.         pointer--;
  956.         ContText++;
  957.     }
  958.     if (Select2 == '2' && RayT == '1')
  959.     {
  960.         fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  961.  
  962.         if (Texture2 == '1')
  963.             fprintf(out, "               texture { %s }\n", Color2);
  964.         else
  965.             fprintf(out, "               pigment { %s }\n", Color2);
  966.     }
  967.     else
  968.     {
  969.         if (Select2 == '2' && RayT == '2')
  970.         {
  971.             fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  972.             fprintf(out, "               %s\n", Color2);
  973.         }
  974.     }
  975.  
  976.     PutsRotate();
  977.     fprintf(out, "} // Fin de la union del texto inferior.\n");
  978.  
  979. }
  980.  
  981. void LineaCircular(void)
  982. {
  983.     double IncRadio;
  984.     double z = -1.1;
  985.     double IncZ;
  986.  
  987.     if (Operacion == 'E')
  988.     {
  989.         IncRadio = (RadioF-Radio)/Long1;
  990.         IncZ = (EndZ -Z)/Long1;
  991.     }
  992.  
  993.     ContText=0;
  994.     pointer=0;
  995.     PutsStartUnion();
  996.     fprintf(out, " // Texto : %s\n\n", TextoS);
  997.     for (cont = 0; cont < Long1; cont ++ )
  998.     {
  999.         if ( TextoS[pointer] != ' ' )
  1000.         {
  1001.             letra = TextoS[pointer];
  1002.             fprintf(out, "       object {\n");
  1003.  
  1004.             PutsFont(font1);
  1005.  
  1006.             angle = cont*( TotalAngle * (M_PI / 180) / Long1);
  1007.  
  1008.             w = StartAngle * (M_PI / 180);
  1009.  
  1010.             x = Radio * cos(  w - angle );
  1011.             y = Radio * sin(  w - angle );
  1012.  
  1013.             if (RayT == '1')
  1014.             {
  1015.                 fprintf(out, "               rotate <%f, %f,", Rix, Riy);
  1016.                 fprintf(out, "%f", (double) (135 - (angle*180/M_PI) ) + Riz );
  1017.                 fprintf(out, ">\n");
  1018.             }
  1019.             else
  1020.             {
  1021.                 fprintf(out, "               rotate <Rix, Riy, ");
  1022.                 fprintf(out, "Riz + %f", (double) (135 - (angle*180/M_PI)) );
  1023.                 fprintf(out, ">\n");
  1024.             }
  1025.  
  1026.             fprintf(out, "               translate <%f, %f, %f>\n", x, y, z);
  1027.  
  1028.             ScaleTexture('1');
  1029.             fprintf(out, "       }\n\n");
  1030.  
  1031.             if (cont < (Long1-1))
  1032.                 PutsEndObject();
  1033.  
  1034.             if (Operacion == 'E')
  1035.             {
  1036.                 Radio+=IncRadio;
  1037.                 z+=IncZ;
  1038.             }
  1039.  
  1040.         }
  1041.         pointer++;
  1042.         ContText++;
  1043.     }
  1044.     ScaleTexture('2');
  1045.     PutsRotate();
  1046.     fprintf(out, "} // Fin de la union del texto.\n");
  1047. }
  1048.  
  1049. void LineasTexto(void)
  1050. {
  1051.     long FilePos, New;
  1052.     double a, b, c;
  1053.     unsigned ObjectSize;
  1054.  
  1055.     PutsTranslateLineal();   /* Ponemos todas las definiciones de formulas */
  1056.     PonerAmbiente();
  1057.  
  1058.     rewind(Temp); /* "Revovinamos" el fichero temporal */
  1059.     y =  CamPos / (1 + Lineas) ; /* Offset de y */
  1060.  
  1061.     for (ContLineas = 1; ContLineas <= Lineas; ContLineas ++)
  1062.     {
  1063.         fread(&ObjectSize, sizeof(unsigned), 1, Temp);
  1064.         fread(ObjectName, ObjectSize, 1, Temp);
  1065.  
  1066.         FilePos = ftell(Temp);
  1067.  
  1068.         fread(&Rx, sizeof(Rx), 1, Temp);
  1069.         fread(&Ry, sizeof(Ry), 1, Temp);
  1070.         fread(&Rz, sizeof(Rz), 1, Temp);
  1071.  
  1072.         fread(&Tx, sizeof(Tx), 1, Temp);
  1073.         fread(&Ty, sizeof(Ty), 1, Temp);
  1074.         fread(&Tz, sizeof(Tz), 1, Temp);
  1075.  
  1076.         fread(&Rix, sizeof(double), 1, Temp);
  1077.         fread(&Riy, sizeof(double), 1, Temp);
  1078.         fread(&Riz, sizeof(double), 1, Temp);
  1079.  
  1080.         fread(&RxOffset, sizeof(RxOffset), 1, Temp);
  1081.         fread(&RyOffset, sizeof(RyOffset), 1, Temp);
  1082.         fread(&RzOffset, sizeof(RzOffset), 1, Temp);
  1083.  
  1084.         fread(&TxOffset, sizeof(TxOffset), 1, Temp);
  1085.         fread(&TyOffset, sizeof(TyOffset), 1, Temp);
  1086.         fread(&TzOffset, sizeof(TzOffset), 1, Temp);
  1087.  
  1088.         fread(&RiOffsetX, sizeof(double), 1, Temp);
  1089.         fread(&RiOffsetY, sizeof(double), 1, Temp);
  1090.         fread(&RiOffsetZ, sizeof(double), 1, Temp);
  1091.  
  1092.         New = ftell(Temp);
  1093.         fseek(Temp, FilePos, SEEK_SET);
  1094.  
  1095.         a = Rx + RxOffset;
  1096.         b = Ry + RyOffset;
  1097.         c = Rz + RzOffset;
  1098.  
  1099.         fwrite(&a, sizeof(Rx), 1, Temp);
  1100.         fwrite(&b, sizeof(Ry), 1, Temp);
  1101.         fwrite(&c, sizeof(Rz), 1, Temp);
  1102.  
  1103.         a = Tx + TxOffset;
  1104.         b = Ty + TyOffset;
  1105.         c = Tz + TzOffset;
  1106.  
  1107.         fwrite(&a, sizeof(Tx), 1, Temp);
  1108.         fwrite(&b, sizeof(Ty), 1, Temp);
  1109.         fwrite(&c, sizeof(Tz), 1, Temp);
  1110.  
  1111.         a = Rix + RiOffsetX;
  1112.         b = Riy + RiOffsetY;
  1113.         c = Riy + RiOffsetZ;
  1114.  
  1115.         fwrite(&a, sizeof(double), 1, Temp);
  1116.         fwrite(&b, sizeof(double), 1, Temp);
  1117.         fwrite(&c, sizeof(double), 1, Temp);
  1118.  
  1119.         fseek(Temp, New, SEEK_SET);
  1120.  
  1121.         fread(&sFx, sizeof(unsigned), 1, Temp);
  1122.         fread(&sFy, sizeof(unsigned), 1, Temp);
  1123.         fread(&sFz, sizeof(unsigned), 1, Temp);
  1124.  
  1125.         strcpy(Fx, "");
  1126.         strcpy(Fy, "");
  1127.         strcpy(Fz, "");
  1128.  
  1129.         fread(Fx, sFx, 1, Temp);
  1130.         fread(Fy, sFy, 1, Temp);
  1131.         fread(Fz, sFz, 1, Temp);
  1132.  
  1133.         fread(&Texture, sizeof(char), 1, Temp);
  1134.         fread(&Select, sizeof(char), 1, Temp);
  1135.  
  1136.         strcpy(Color, "");
  1137.         fread(&sColor, sizeof(unsigned), 1, Temp);
  1138.         fread(Color, sColor, 1, Temp);
  1139.  
  1140.         fread(&font1, sizeof(char), 1, Temp);
  1141.  
  1142.         strcpy(TextoS, "");
  1143.         fread(&sTextoS, sizeof(unsigned), 1, Temp);
  1144.         fread(&TextoS, sTextoS, 1, Temp);
  1145.  
  1146.         fread(&Scale, sizeof(Scale), 1, Temp);
  1147.         fread(&LongPag, sizeof(LongPag), 1, Temp);
  1148.  
  1149.         ContText=0;
  1150.         Long1 = strlen(TextoS);
  1151.         pointer=0; /* Apuntamos al primer carcater */
  1152.         PutsStartUnion();
  1153.         fprintf(out, " // Texto : %s\n\n", TextoS);
  1154.         for (cont = 0; cont < Long1; cont ++ )
  1155.         {
  1156.             if ( TextoS[pointer] != ' ' )
  1157.             {
  1158.                 letra = TextoS[pointer];
  1159.                 fprintf(out, "       object {\n");
  1160.  
  1161.                 PutsFont(font1);
  1162.  
  1163.                 x = LongPag * Scale;
  1164.  
  1165.                 if (RayT == '1')
  1166.                     fprintf(out, "               rotate <%f, %f, %f>\n", Rix, Riy, Riz);
  1167.                 else
  1168.                     fprintf(out, "               rotate <Rix%d, Riy%d, Riz%d>\n", ContLineas, ContLineas, ContLineas);
  1169.  
  1170.                 fprintf(out, "               translate <%f, %f, -1.1>\n", (- x / 2.0) + cont * ( (LongPag / Long1) * Scale), (-CamPos / 2.0) + (y * ContLineas) );
  1171.  
  1172.                 ScaleTexture('1');
  1173.                 fprintf(out, "       }\n\n");
  1174.  
  1175.                 if (cont < (Long1-1))
  1176.                     PutsEndObject();
  1177.             }
  1178.             pointer++;
  1179.             ContText++;
  1180.         }
  1181.         ScaleTexture('2');
  1182.         PutsRotate();
  1183.         fprintf(out, "} // Fin de la union del texto.\n");
  1184.     }
  1185. }
  1186.  
  1187. void ChoseFont(char *font)
  1188. {
  1189.     char dOn[255];
  1190.  
  1191.     if (RayT == '1')
  1192.     {
  1193.         printf("\n (1) Chars (mayusculas)\n (2) Font Round\n (3) Objeto definido por el usuario\n\nEligue tipo de letra (1/2/3) [%c]: ", fontF);
  1194.         (*font) = getc(stdin);
  1195.  
  1196.         if ((*font) == '\n')
  1197.             *font = fontF;
  1198.         else
  1199.         {
  1200.             getc(stdin);
  1201.             fontF = *font;
  1202.         }
  1203.  
  1204.         if ((*font) == '3')
  1205.         {
  1206.             printf("Introduce el nombre del fichero incluido [shapes.inc]: ");
  1207.             gets(Buffer);
  1208.  
  1209.             if (Buffer[0])
  1210.                 strcpy(IncludeFile, Buffer);
  1211.             else
  1212.                 strcpy(IncludeFile, "shapes.inc");
  1213.  
  1214.             printf("Introduce el nombre del objeto [Paraboloid_X]: ");
  1215.             gets(Buffer);
  1216.  
  1217.             if (Buffer[0])
  1218.                 strcpy(ObjectName, Buffer);
  1219.             else
  1220.                 strcpy(ObjectName, "Paraboloid_X");
  1221.         }
  1222.     }
  1223.     else
  1224.     {
  1225.         printf("\n (1) True type extraida con el GetFont.bat\n (2) Objeto definido por el usuario\n\nEligue tipo de letra (1/2) [%c]: ", fontF);
  1226.         (*font) = getc(stdin);
  1227.  
  1228.         if ((*font) == '\n')
  1229.             *font = fontF;
  1230.         else
  1231.         {
  1232.             getc(stdin);
  1233.             fontF = *font;
  1234.         }
  1235.  
  1236.         if ((*font) == '2')
  1237.         {
  1238.             printf("Introduce el nombre del fichero incluido [shapes.inc]: ");
  1239.             gets(Buffer);
  1240.  
  1241.             if (Buffer[0])
  1242.                 strcpy(IncludeFile, Buffer);
  1243.             else
  1244.                 strcpy(IncludeFile, "shapes.inc");
  1245.  
  1246.             printf("Introduce el nombre del objeto [sphere <0,0,0>, 6]: ");
  1247.             gets(Buffer);
  1248.  
  1249.             if (Buffer[0])
  1250.                 strcpy(ObjectName, Buffer);
  1251.             else
  1252.                 strcpy(ObjectName, "sphere <0,0,0>, 6");
  1253.         }
  1254.         else
  1255.         {
  1256.             if (!YetFont)
  1257.             {
  1258.                 printf("Introduce el nombre del fichero incluido [arial.inc]: ");
  1259.                 gets(Buffer);
  1260.  
  1261.                 if (Buffer[0])
  1262.                     strcpy(IncludeFile, Buffer);
  1263.                 else
  1264.                     strcpy(IncludeFile, "arial.inc");
  1265.  
  1266.                 YetFont = True;
  1267.             }
  1268.  
  1269.         }
  1270.     }
  1271. }
  1272.  
  1273. void PutsFont(char font)
  1274. {
  1275.     if (RayT == '1')
  1276.     {
  1277.         switch (font)   {
  1278.                     case '1': {
  1279.                                 letra = toupper(letra);
  1280.  
  1281.                                 switch (letra) {
  1282.                                                 case '$': fprintf(out, "               char_Dol\n"); break;
  1283.                                                 case '(': fprintf(out, "               char_LPar\n"); break;
  1284.                                                 case ')': fprintf(out, "               char_RPar\n"); break;
  1285.                                                 case '[': fprintf(out, "               char_LSqu\n"); break;
  1286.                                                 case ']': fprintf(out, "               char_RSqu\n"); break;
  1287.                                                 case '+': fprintf(out, "               char_Plus\n");  break;
  1288.                                                 case '-': fprintf(out, "               char_Dash\n");  break;
  1289.                                                 case '%': fprintf(out, "               char_Perc\n"); break;
  1290.                                                 case '^': fprintf(out, "               char_Hat\n");  break;
  1291.                                                 case '&': fprintf(out, "               char_Amps\n"); break;
  1292.                                                 case '*': fprintf(out, "               char_Astr\n"); break;
  1293.                                                 case '!': fprintf(out, "               char_ExclPt\n"); break;
  1294.                                                 case '#': fprintf(out, "               char_Num\n"); break;
  1295.                                                 case '@': fprintf(out, "               char_AtSign\n"); break;
  1296.                                                 default: fprintf(out, "               char_%c\n", letra); break;
  1297.                 }
  1298.                     } break;
  1299.  
  1300.                     case '2': fprintf(out, "               Font_Round_%c\n", letra); break;
  1301.  
  1302.                     case '3': fprintf(out, "               %s\n", ObjectName); break;
  1303.         }
  1304.     }
  1305.     else
  1306.     {
  1307.         if (font == '1')
  1308.             fprintf(out, "               char_%c\n", letra);
  1309.         else
  1310.             fprintf(out, "               %s\n", ObjectName);
  1311.     }
  1312. }
  1313.  
  1314. void ScaleTexture(char Site)
  1315. {
  1316.     if (Select == Site)
  1317.     {
  1318.         fprintf(out, "               scale <%f, %f, %f>\n", Scale, Scale, Scale);
  1319.  
  1320.         if (RayT == '1')
  1321.         {
  1322.             if (Texture == '1')
  1323.                 fprintf(out, "               texture { %s }\n", Color);
  1324.             else
  1325.                 if (Texture == '0')
  1326.                     fprintf(out, "               pigment { %s }\n", Color);
  1327.                 else
  1328.                     fprintf(out, "               texture { Texture%d }\n", ContText % NumText);
  1329.         }
  1330.         else
  1331.         {
  1332.             if (Texture != '2')
  1333.                 fprintf(out, "               %s\n", Color);
  1334.             else
  1335.                 fprintf(out, "                Texture%d \n", ContText % NumText);
  1336.         }
  1337.     }
  1338. }
  1339.  
  1340. void SetTexture(void)
  1341. {
  1342.     char Tmp[255];
  1343.  
  1344.     if (RayT == '1')
  1345.     {
  1346.         printf ("\n (0) Color\n (1) Textura\n (2) Multitextura\n\nSuperficie en los objetos [0] : ");
  1347.         Texture = getc(stdin);
  1348.  
  1349.         if (Texture == '\n')
  1350.             Texture = '0';
  1351.         else
  1352.             getc(stdin);
  1353.  
  1354.             if (Texture == '1')
  1355.                 strcpy(Tmp, "Jade");
  1356.             else
  1357.                 strcpy(Tmp, "Red");
  1358.  
  1359.         if (!(Texture == '2'))
  1360.         {
  1361.             printf ("Ahora el nombre del color o la textura de las letras [%s] : ", Tmp);
  1362.             gets(Buffer);
  1363.  
  1364.             if (Buffer[0])
  1365.                 strcpy(Color, Buffer);
  1366.             else
  1367.                 strcpy(Color, Tmp);
  1368.         }
  1369.         else
  1370.         {
  1371.             if (!YetMulti)
  1372.             {
  1373.                 if (RayT == '1')
  1374.                     strcpy(Tmp, "multpov.inc");
  1375.                 else
  1376.                     strcpy(Tmp, "multpoly.inc");
  1377.  
  1378.                 printf ("Introduce el nombre del fichero de texturas [%s]: ", Tmp);
  1379.                 gets(Buffer);
  1380.  
  1381.                 if (Buffer[0])
  1382.                     strcpy(TextName, Buffer);
  1383.                 else
  1384.                     strcpy(TextName, Tmp);
  1385.  
  1386.                 printf ("Cuantas texturas hay en el fichero %s [12]: ", TextName);
  1387.                 gets(Buffer);
  1388.  
  1389.                 if (Buffer[0])
  1390.                     NumText = atoi(Buffer);
  1391.                 else
  1392.                     NumText = 12;
  1393.  
  1394.                 YetMulti = True;
  1395.             }
  1396.         }
  1397.     }
  1398.     else
  1399.     {
  1400.         printf ("\n (1) Color o Textura\n (2) Multitextura\n\nSuperficie en los objetos [1] : ");
  1401.         Texture = getc(stdin);
  1402.  
  1403.         if (Texture == '\n')
  1404.             Texture = '1';
  1405.         else
  1406.             getc(stdin);
  1407.  
  1408.         if (Texture == '1')
  1409.         {
  1410.             printf ("Ahora el nombre del color o la textura de las letras [matte_red] : ", Tmp);
  1411.             gets(Buffer);
  1412.  
  1413.             if (Buffer[0])
  1414.                 strcpy(Color, Buffer);
  1415.             else
  1416.                 strcpy(Color, "matte_red");
  1417.         }
  1418.         else
  1419.         {
  1420.             if (!YetMulti)
  1421.             {
  1422.                 if (RayT == '1')
  1423.                     strcpy(Tmp, "multpov.inc");
  1424.                 else
  1425.                     strcpy(Tmp, "multpoly.inc");
  1426.  
  1427.                 printf ("Introduce el nombre del fichero de texturas [%s]: ", Tmp);
  1428.                 gets(Buffer);
  1429.  
  1430.                 if (Buffer[0])
  1431.                     strcpy(TextName, Buffer);
  1432.                 else
  1433.                     strcpy(TextName, Tmp);
  1434.  
  1435.                 printf ("Cuantas texturas hay en el fichero %s [12]: ", TextName);
  1436.                 gets(Buffer);
  1437.  
  1438.                 if (Buffer[0])
  1439.                     NumText = atoi(Buffer);
  1440.                 else
  1441.                     NumText = 12;
  1442.  
  1443.                 YetMulti = True;
  1444.             }
  1445.         }
  1446.     }
  1447.  
  1448.     printf ("\n (1) Individuales \n (2) Agrupadas\n\n Como quieres los objetos [1] : ");
  1449.     Select = getc(stdin);
  1450.  
  1451.     if (Select == '\n')
  1452.         Select = '1';
  1453.     else
  1454.         getc(stdin);
  1455.  
  1456.     if (Operacion == '2' || Operacion == 'Y')
  1457.     {
  1458.         if (RayT == '2')
  1459.         {
  1460.             printf ("\n (1) Color o Textura\n (2) Multitextura\n\nSuperficie en los objetos [1] : ");
  1461.             Texture2 = getc(stdin);
  1462.  
  1463.             if (Texture2 == '\n')
  1464.                 Texture2 = '1';
  1465.             else
  1466.                 getc(stdin);
  1467.  
  1468.             if (Texture2 == '1')
  1469.             {
  1470.                 printf ("Ahora el nombre del color o la textura de las letras [matte_red] : ", Tmp);
  1471.                 gets(Buffer);
  1472.  
  1473.                 if (Buffer[0])
  1474.                     strcpy(Color2, Buffer);
  1475.                 else
  1476.                     strcpy(Color2, "matte_red");
  1477.             }
  1478.         }
  1479.         else
  1480.         {
  1481.             printf ("\n (0) Color\n (1) Textura \n\nSuperficie en los objetos inferiores [%c] : ", Texture);
  1482.             Texture2 = getc(stdin);
  1483.  
  1484.             if (Texture2 == '\n')
  1485.                 Texture2 = Texture;
  1486.             else
  1487.                 getc(stdin);
  1488.  
  1489.             printf ("Ahora el nombre del color o la textura de las letras [%s] : ", Color);
  1490.             gets(Buffer);
  1491.  
  1492.             if (Buffer[0])
  1493.                 strcpy(Color2, Buffer);
  1494.             else
  1495.                 strcpy(Color2, Color);
  1496.         }
  1497.  
  1498.         printf ("\n (1) Individuales \n (2) Agrupadas\n\n Como quieres los objetos [%c] : ", Select);
  1499.         Select2 = getc(stdin);
  1500.  
  1501.         if (Select2 == '\n')
  1502.             Select2 = Select;
  1503.         else
  1504.             getc(stdin);
  1505.     }
  1506. }
  1507.  
  1508. void SetRotate(void)
  1509. {
  1510.     printf("\nAhora vamos a hacer un Rotate\n\n");
  1511.     printf ("Introduce el angulo de comienzo en x [0]: ");
  1512.     gets(Buffer);
  1513.  
  1514.     if (Buffer[0])
  1515.         Rx = atof(Buffer);
  1516.     else
  1517.         Rx = 0;
  1518.  
  1519.     printf ("Introduce el angulo de comienzo en y [0]: ");
  1520.     gets(Buffer);
  1521.  
  1522.     if (Buffer[0])
  1523.         Ry = atof(Buffer);
  1524.     else
  1525.         Ry = 0;
  1526.  
  1527.     printf ("Introduce el angulo de comienzo en z [0]: ");
  1528.     gets(Buffer);
  1529.  
  1530.     if (Buffer[0])
  1531.         Rz = atof(Buffer);
  1532.     else
  1533.         Rz = 0;
  1534.  
  1535.     if (Frames > 1)
  1536.     {
  1537.         printf ("Introduce el incremento del angulo en x [0]: ");
  1538.         gets(Buffer);
  1539.  
  1540.         if (Buffer[0])
  1541.             RxOffset = atof(Buffer);
  1542.         else
  1543.             RxOffset = 0;
  1544.  
  1545.         printf ("Introduce el incremento del angulo en y [0]: ");
  1546.         gets(Buffer);
  1547.  
  1548.         if (Buffer[0])
  1549.             RyOffset = atof(Buffer);
  1550.         else
  1551.             RyOffset = 0;
  1552.  
  1553.         printf ("Introduce el incremento del angulo en z [0]: ");
  1554.         gets(Buffer);
  1555.  
  1556.         if (Buffer[0])
  1557.             RzOffset = atof(Buffer);
  1558.         else
  1559.             RzOffset = 0;
  1560.     }
  1561.  
  1562.     printf("\nAhora vamos a hacer un Rotate Interno\n\n");
  1563.     printf ("Introduce el angulo de comienzo en x [0]: ");
  1564.     gets(Buffer);
  1565.  
  1566.     if (Buffer[0])
  1567.         Rix = atof(Buffer);
  1568.     else
  1569.         Rix = 0;
  1570.  
  1571.     printf ("Introduce el angulo de comienzo en y [0]: ");
  1572.     gets(Buffer);
  1573.  
  1574.     if (Buffer[0])
  1575.         Riy = atof(Buffer);
  1576.     else
  1577.         Riy = 0;
  1578.  
  1579.     printf ("Introduce el angulo de comienzo en z [0]: ");
  1580.     gets(Buffer);
  1581.  
  1582.     if (Buffer[0])
  1583.         Riz = atof(Buffer);
  1584.     else
  1585.         Riz = 0;
  1586.  
  1587.     if (Frames > 1)
  1588.     {
  1589.         printf ("Introduce el incremento del angulo en x [0]: ");
  1590.         gets(Buffer);
  1591.  
  1592.         if (Buffer[0])
  1593.             RiOffsetX = atof(Buffer);
  1594.         else
  1595.             RiOffsetX = 0;
  1596.  
  1597.         printf ("Introduce el incremento del angulo en y [0]: ");
  1598.         gets(Buffer);
  1599.  
  1600.         if (Buffer[0])
  1601.             RiOffsetY = atof(Buffer);
  1602.         else
  1603.             RiOffsetY = 0;
  1604.  
  1605.         printf ("Introduce el incremento del angulo en z [0]: ");
  1606.         gets(Buffer);
  1607.  
  1608.         if (Buffer[0])
  1609.             RiOffsetZ = atof(Buffer);
  1610.         else
  1611.             RiOffsetZ = 0;
  1612.     }
  1613. }
  1614.  
  1615. void PutsRotate(void)
  1616. {
  1617.     if (RayT == '1')
  1618.         fprintf(out, "       rotate <%f, %f, %f>\n", Rx, Ry, Rz);
  1619.     else
  1620.     {
  1621.         if (Operacion == 'L')
  1622.             fprintf(out, "       rotate <Rx%d, Ry%d, Rz%d>\n", ContLineas, ContLineas, ContLineas);
  1623.         else
  1624.             fprintf(out, "       rotate <Rx, Ry, Rz>\n");
  1625.     }
  1626.  
  1627.     if (Frames > 1 )
  1628.     {
  1629.         if (Operacion == 'L')
  1630.             fprintf(out, "       translate <Fx%d, Fy%d, Fz%d>\n", ContLineas, ContLineas, ContLineas);
  1631.         else
  1632.             fprintf(out, "       translate <Fx, Fy, Fz>\n");
  1633.     }
  1634. }
  1635.  
  1636. void PutsDescription(void)
  1637. {
  1638.     unsigned ObjectSize;
  1639.  
  1640.     /* Escribimos la descripcion en la cabecera del fichero destino.   */
  1641.  
  1642.     if (RayT == '2')
  1643.         fprintf(out, "define PI 3.141592645\n\n");
  1644.  
  1645.     fprintf(out, "// Opciones de generacion del fichero %s\n", FileName);
  1646.  
  1647.     switch (Operacion) {
  1648.  
  1649.                         case '1':
  1650.  
  1651.                         case 'Y':
  1652.  
  1653.                         case '2': {
  1654.                                    fprintf(out, "// Radio de la circunferencia: ");
  1655.                                    fprintf(out, "%f\n", Radio);
  1656.  
  1657.                                    fprintf(out, "// Texto superior: ");
  1658.                                    fprintf(out, "%s\n", TextoS);
  1659.  
  1660.                                    fprintf(out, "// Texto inferior: ");
  1661.                                    fprintf(out, "%s\n", TextoI);
  1662.  
  1663.                                    fprintf(out, "// Escala del font: ");
  1664.                                    fprintf(out, "%f\n", Scale);
  1665.  
  1666.                                    if  ( font1 == '1' )
  1667.                                         fprintf(out, "// Tipo de letra superior: Chars.\n");
  1668.                                    else
  1669.                                         if (font1 == '2')
  1670.                                             fprintf(out, "// Tipo de letra superior : Font Round.\n");
  1671.                                         else
  1672.                                             fprintf(out, "// Grafico superior definido por el usuario : %s.\n", ObjectName);
  1673.  
  1674.                                     if  ( font2 == '1' )
  1675.                                         fprintf(out, "// Tipo de letra inferior: Chars.\n");
  1676.                                     else
  1677.                                         if (font2 == '2')
  1678.                                             fprintf(out, "// Tipo de letra inferior : Font Round.\n");
  1679.                                         else
  1680.                                             fprintf(out, "// Grafico inferior definido por el usuario : %s.\n", ObjectName);
  1681.  
  1682.                                     if ( Texture == '1')
  1683.                                         fprintf(out, "// Textura del objeto: %s\n", Color);
  1684.                                     else
  1685.                                         fprintf(out, "// Color del objeto: %s\n", Color);
  1686.                         } break;
  1687.  
  1688.                         case 'E':
  1689.  
  1690.                         case 'C': {
  1691.                                    if (Operacion == 'E')
  1692.                                    {
  1693.                                         fprintf(out, "// Radio Inicial de la circunferencia: ");
  1694.                                         fprintf(out, "%f\n", Radio);
  1695.  
  1696.                                         fprintf(out, "// Radio Final de la circunferencia: ");
  1697.                                         fprintf(out, "%f\n", RadioF);
  1698.                                    }
  1699.                                    else
  1700.                                    {
  1701.                                         fprintf(out, "// Radio de la circunferencia: ");
  1702.                                         fprintf(out, "%f\n", Radio);
  1703.                                    }
  1704.  
  1705.                                    fprintf(out, "// Texto: ");
  1706.                                    fprintf(out, "%s\n", TextoS);
  1707.  
  1708.                                    fprintf(out, "// Escala del font: ");
  1709.                                    fprintf(out, "%f\n", Scale);
  1710.  
  1711.                                    if  ( font1 == '1' )
  1712.                                         fprintf(out, "// Tipo de letra: Chars.\n");
  1713.                                    else
  1714.                                         if (font1 == '2')
  1715.                                             fprintf(out, "// Tipo de letra: Font Round.\n");
  1716.                                         else
  1717.                                             fprintf(out, "// Grafico definido por el usuario : %s.\n", ObjectName);
  1718.  
  1719.                                     if ( Texture == '1')
  1720.                                         fprintf(out, "// Textura del objeto: %s\n", Color);
  1721.                                     else
  1722.                                         fprintf(out, "// Color del objeto: %s\n", Color);
  1723.  
  1724.                                     fprintf(out, "// Angulo Total : ");
  1725.                                     fprintf(out, "%f\n", TotalAngle);
  1726.  
  1727.                                     fprintf(out, "// Angulo de cominenzo : ");
  1728.                                     fprintf(out, "%f\n", StartAngle);
  1729.                         } break;
  1730.  
  1731.                         case 'L': {
  1732.                                     rewind(Temp); /* "Revovinamos" el fichero temporal */
  1733.  
  1734.                                     for (ContLineas = 1; ContLineas <= Lineas; ContLineas ++)
  1735.                                     {
  1736.                                         fread(&ObjectSize, sizeof(unsigned), 1, Temp);
  1737.                                         fread(ObjectName, ObjectSize, 1, Temp);
  1738.  
  1739.                                         fread(&Rx, sizeof(Rx), 1, Temp);
  1740.                                         fread(&Ry, sizeof(Ry), 1, Temp);
  1741.                                         fread(&Rz, sizeof(Rz), 1, Temp);
  1742.  
  1743.                                         fread(&Tx, sizeof(Tx), 1, Temp);
  1744.                                         fread(&Ty, sizeof(Ty), 1, Temp);
  1745.                                         fread(&Tz, sizeof(Tz), 1, Temp);
  1746.  
  1747.                                         fread(&Rix, sizeof(double), 1, Temp);
  1748.                                         fread(&Riy, sizeof(double), 1, Temp);
  1749.                                         fread(&Riz, sizeof(double), 1, Temp);
  1750.  
  1751.                                         fread(&RxOffset, sizeof(RxOffset), 1, Temp);
  1752.                                         fread(&RyOffset, sizeof(RyOffset), 1, Temp);
  1753.                                         fread(&RzOffset, sizeof(RzOffset), 1, Temp);
  1754.  
  1755.                                         fread(&TxOffset, sizeof(TxOffset), 1, Temp);
  1756.                                         fread(&TyOffset, sizeof(TyOffset), 1, Temp);
  1757.                                         fread(&TzOffset, sizeof(TzOffset), 1, Temp);
  1758.  
  1759.                                         fread(&RiOffsetX, sizeof(double), 1, Temp);
  1760.                                         fread(&RiOffsetY, sizeof(double), 1, Temp);
  1761.                                         fread(&RiOffsetZ, sizeof(double), 1, Temp);
  1762.  
  1763.                                         fread(&sFx, sizeof(unsigned), 1, Temp);
  1764.                                         fread(&sFy, sizeof(unsigned), 1, Temp);
  1765.                                         fread(&sFz, sizeof(unsigned), 1, Temp);
  1766.  
  1767.                                         strcpy(Fx, "");
  1768.                                         strcpy(Fy, "");
  1769.                                         strcpy(Fz, "");
  1770.  
  1771.                                         fread(Fx, sFx, 1, Temp);
  1772.                                         fread(Fy, sFy, 1, Temp);
  1773.                                         fread(Fz, sFz, 1, Temp);
  1774.  
  1775.                                         fread(&Texture, sizeof(char), 1, Temp);
  1776.                                         fread(&Select, sizeof(char), 1, Temp);
  1777.  
  1778.                                         strcpy(Color, "");
  1779.                                         fread(&sColor, sizeof(unsigned), 1, Temp);
  1780.                                         fread(Color, sColor, 1, Temp);
  1781.  
  1782.                                         fread(&font1, sizeof(char), 1, Temp);
  1783.  
  1784.                                         strcpy(TextoS, "");
  1785.                                         fread(&sTextoS, sizeof(unsigned), 1, Temp);
  1786.                                         fread(TextoS, sTextoS, 1, Temp);
  1787.  
  1788.                                         fread(&Scale, sizeof(Scale), 1, Temp);
  1789.                                         fread(&LongPag, sizeof(LongPag), 1, Temp);
  1790.  
  1791.                                         fprintf(out, "// Linea %d: ", ContLineas);
  1792.                                         fprintf(out, "%s\n", TextoS);
  1793.  
  1794.                                         fprintf(out, "// Escala del font: ");
  1795.                                         fprintf(out, "%f\n", Scale);
  1796.  
  1797.                                         if  ( font1 == '1' )
  1798.                                             fprintf(out, "// Tipo de letra: Chars.\n");
  1799.                                         else
  1800.                                             if (font1 == '2')
  1801.                                                 fprintf(out, "// Tipo de letra: Font Round.\n");
  1802.                                             else
  1803.                                                 fprintf(out, "// Grafico definido por el usuario : %s.\n", ObjectName);
  1804.  
  1805.                                         if ( Texture == '1')
  1806.                                             fprintf(out, "// Textura del objeto: %s\n", Color);
  1807.                                         else
  1808.                                             fprintf(out, "// Color del objeto: %s\n", Color);
  1809.  
  1810.                                         fprintf(out, "// Separacion de la letras: ");
  1811.                                         fprintf(out, "%f\n", Separacion);
  1812.  
  1813.                                         fprintf(out, "// Longitud de linea: ");
  1814.                                         fprintf(out, "%f\n", LongPag);
  1815.                                     } /* Fin del For */
  1816.                         } break;
  1817.     } /* Fin del Case */
  1818.  
  1819.     fprintf(out, "// Rotacion del objeto en X: ");
  1820.     fprintf(out, "%f\n", Rx);
  1821.  
  1822.     fprintf(out, "// Rotacion del objeto en Y: ");
  1823.     fprintf(out, "%f\n", Ry);
  1824.  
  1825.     fprintf(out, "// Rotacion del objeto en Z: ");
  1826.     fprintf(out, "%f\n", Rz);
  1827.  
  1828.     fprintf(out, "// Rotacion Interna del objeto en X: ");
  1829.     fprintf(out, "%f\n", Rix);
  1830.  
  1831.     fprintf(out, "// Rotacion Interna del objeto en Y: ");
  1832.     fprintf(out, "%f\n", Riy);
  1833.  
  1834.     fprintf(out, "// Rotacion Interna del objeto en Z: ");
  1835.     fprintf(out, "%f\n", Riz);
  1836.  
  1837.     fprintf(out, "// Posicion a priori del objeto en X: ");
  1838.     fprintf(out, "%f\n", Tx);
  1839.  
  1840.     fprintf(out, "// Posicion a priori del objeto en Y: ");
  1841.     fprintf(out, "%f\n", Ty);
  1842.  
  1843.     fprintf(out, "// Posicion a priori del objeto en Z: ");
  1844.     fprintf(out, "%f\n", Tz);
  1845.  
  1846.     fprintf(out, "// Lejania de la camara: ");
  1847.     fprintf(out, "%f\n", CamPos);
  1848.  
  1849.     fprintf(out, "// Factor de zoom: ");
  1850.     fprintf(out, "%f\n\n", Zoom);
  1851. }
  1852.  
  1853. void PutsTranslate(void)
  1854. {
  1855.     if (Operacion == 'L' && Frames > 1 && RayT == '1')
  1856.     {
  1857.         fprintf(out, "#declare Tx%d = %f\n", ContLineas, Tx);
  1858.         fprintf(out, "#declare Ty%d = %f\n", ContLineas, Ty);
  1859.         fprintf(out, "#declare Tz%d = %f\n", ContLineas, Tz);
  1860.  
  1861.         fprintf(out, "#declare Fx%d = %s\n", ContLineas, Fx);
  1862.         fprintf(out, "#declare Fy%d = %s\n", ContLineas, Fy);
  1863.         fprintf(out, "#declare Fz%d = %s\n", ContLineas, Fz);
  1864.     }
  1865.     else
  1866.     {
  1867.         if (RayT == '1' && Frames > 1)
  1868.         {
  1869.             Tx += TxOffset;
  1870.             Ty += TyOffset;
  1871.             Tz += TzOffset;
  1872.  
  1873.             fprintf(out, "#declare Tx = %f\n", Tx);
  1874.             fprintf(out, "#declare Ty = %f\n", Ty);
  1875.             fprintf(out, "#declare Tz = %f\n", Tz);
  1876.  
  1877.             fprintf(out, "#declare Fx = %s\n", Fx);
  1878.             fprintf(out, "#declare Fy = %s\n", Fy);
  1879.             fprintf(out, "#declare Fz = %s\n", Fz);
  1880.         }
  1881.         fprintf(out, "\n");
  1882.     }
  1883.  
  1884.     if (Operacion == 'L' && RayT == '2')
  1885.     {
  1886.         fprintf(out, "define Tx%d %f+(frame*%f)\n", ContLineas, Tx, TxOffset);
  1887.         fprintf(out, "define Ty%d %f+(frame*%f)\n", ContLineas, Ty, TyOffset);
  1888.         fprintf(out, "define Tz%d %f+(frame*%f)\n", ContLineas, Tz, TzOffset);
  1889.  
  1890.         fprintf(out, "define Rx%d %f+(frame*%f)\n", ContLineas, Rx, RxOffset);
  1891.         fprintf(out, "define Ry%d %f+(frame*%f)\n", ContLineas, Ry, RyOffset);
  1892.         fprintf(out, "define Rz%d %f+(frame*%f)\n", ContLineas, Rz, RzOffset);
  1893.  
  1894.         fprintf(out, "define Rix%d %f+(frame*%f)\n", ContLineas, Rix, RiOffsetX);
  1895.         fprintf(out, "define Riy%d %f+(frame*%f)\n", ContLineas, Riy, RiOffsetY);
  1896.         fprintf(out, "define Riz%d %f+(frame*%f)\n", ContLineas, Riz, RiOffsetZ);
  1897.  
  1898.         if (Frames > 1)
  1899.         {
  1900.             fprintf(out, "define Fx%d %s\n", ContLineas, Fx);
  1901.             fprintf(out, "define Fy%d %s\n", ContLineas, Fy);
  1902.             fprintf(out, "define Fz%d %s\n", ContLineas, Fz);
  1903.         }
  1904.     }
  1905.     else
  1906.     {
  1907.         if (RayT == '2')
  1908.         {
  1909.             fprintf(out, "define Tx %f+(frame*%f)\n", Tx, TxOffset);
  1910.             fprintf(out, "define Ty %f+(frame*%f)\n", Ty, TyOffset);
  1911.             fprintf(out, "define Tz %f+(frame*%f)\n", Tz, TzOffset);
  1912.  
  1913.             fprintf(out, "define Rx %f+(frame*%f)\n", Rx, RxOffset);
  1914.             fprintf(out, "define Ry %f+(frame*%f)\n", Ry, RyOffset);
  1915.             fprintf(out, "define Rz %f+(frame*%f)\n", Rz, RzOffset);
  1916.  
  1917.             fprintf(out, "define Rix %f+(frame*%f)\n", Rix, RiOffsetX);
  1918.             fprintf(out, "define Riy %f+(frame*%f)\n", Riy, RiOffsetY);
  1919.             fprintf(out, "define Riz %f+(frame*%f)\n", Riz, RiOffsetZ);
  1920.  
  1921.             if (Frames > 1)
  1922.             {
  1923.                 fprintf(out, "define Fx %s\n", Fx);
  1924.                 fprintf(out, "define Fy %s\n", Fy);
  1925.                 fprintf(out, "define Fz %s\n", Fz);
  1926.             }
  1927.         }
  1928.         fprintf(out, "\n");
  1929.     }
  1930. }
  1931.  
  1932. void SetTranslate(void)
  1933. {
  1934.     printf("\nAhora vamos a hacer un Translate\n\n");
  1935.     printf ("Introduce el offset de comienzo en x [0]: ");
  1936.     gets(Buffer);
  1937.  
  1938.     if (Buffer[0])
  1939.         Tx = atof(Buffer);
  1940.     else
  1941.         Tx = 0;
  1942.  
  1943.     printf ("Introduce el offset de comienzo en y [0]: ");
  1944.     gets(Buffer);
  1945.  
  1946.     if (Buffer[0])
  1947.         Ty = atof(Buffer);
  1948.     else
  1949.         Ty = 0;
  1950.  
  1951.     printf ("Introduce el offset de comienzo en z [0]: ");
  1952.     gets(Buffer);
  1953.  
  1954.     if (Buffer[0])
  1955.         Tz = atof(Buffer);
  1956.     else
  1957.         Tz = 0;
  1958.  
  1959.     if (Frames > 1)
  1960.     {
  1961.         printf ("Introduce el incremento de la x [0]: ");
  1962.         gets(Buffer);
  1963.  
  1964.         if (Buffer[0])
  1965.             TxOffset = atof(Buffer);
  1966.         else
  1967.             TxOffset = 0;
  1968.  
  1969.         printf ("Introduce el incremento de la y [0]: ");
  1970.         gets(Buffer);
  1971.  
  1972.         if (Buffer[0])
  1973.             TyOffset = atof(Buffer);
  1974.         else
  1975.             TyOffset = 0;
  1976.  
  1977.         printf ("Introduce el incremento de la z [0]: ");
  1978.         gets(Buffer);
  1979.  
  1980.         if (Buffer[0])
  1981.             TzOffset = atof(Buffer);
  1982.         else
  1983.             TzOffset = 0;
  1984.  
  1985.         if (!(Operacion == 'L'))
  1986.         {
  1987.             printf ("Introduce la formula de la x [Tx]: ");
  1988.             gets(Buffer);
  1989.  
  1990.             if (Buffer[0])
  1991.                 strcpy(Fx, Buffer);
  1992.             else
  1993.                 strcpy(Fx, "Tx");
  1994.  
  1995.             printf ("Introduce la formula de la y [Ty]: ");
  1996.             gets(Buffer);
  1997.  
  1998.             if (Buffer[0])
  1999.                 strcpy(Fy, Buffer);
  2000.             else
  2001.                 strcpy(Fy, "Ty");
  2002.  
  2003.             printf ("Introduce la formula de la z [Tz]: ");
  2004.             gets(Buffer);
  2005.  
  2006.             if (Buffer[0])
  2007.                 strcpy(Fz, Buffer);
  2008.             else
  2009.                 strcpy(Fz, "Tz");
  2010.         }
  2011.         else
  2012.         {
  2013.             printf ("Introduce la formula de la x [Tx%d]: ", ContLineas);
  2014.             gets(Buffer);
  2015.  
  2016.             if (Buffer[0])
  2017.                 strcpy(Fx, Buffer);
  2018.             else
  2019.                 sprintf(Fx, "Tx%d", ContLineas);
  2020.  
  2021.             printf ("Introduce la formula de la y [Ty%d]: ", ContLineas);
  2022.             gets(Buffer);
  2023.  
  2024.             if (Buffer[0])
  2025.                 strcpy(Fy, Buffer);
  2026.             else
  2027.                 sprintf(Fy, "Ty%d", ContLineas);
  2028.  
  2029.             printf ("Introduce la formula de la z [Tz%d]: ", ContLineas);
  2030.             gets(Buffer);
  2031.  
  2032.             if (Buffer[0])
  2033.                 strcpy(Fz, Buffer);
  2034.             else
  2035.                 sprintf(Fz, "Tz%d", ContLineas);
  2036.         }
  2037.     }
  2038. }
  2039.  
  2040. void SetFrames(void)
  2041. {
  2042.     printf ("Número de frames (eligue 1 si no quieres animaciones) [1]: ");
  2043.     gets(Buffer);
  2044.  
  2045.     if (Buffer[0])
  2046.         Frames = atoi(Buffer);
  2047.     else
  2048.         Frames = 1;
  2049. }
  2050.  
  2051. void PutsTranslateLineal(void)
  2052. {
  2053.     unsigned ObjectSize;
  2054.  
  2055.     rewind(Temp);
  2056.  
  2057.     for (ContLineas = 1; ContLineas <= Lineas; ContLineas ++)
  2058.     {
  2059.  
  2060.         fread(&ObjectSize, sizeof(unsigned), 1, Temp);
  2061.         fread(ObjectName, ObjectSize, 1, Temp);
  2062.  
  2063.         fread(&Rx, sizeof(Rx), 1, Temp);
  2064.         fread(&Ry, sizeof(Ry), 1, Temp);
  2065.         fread(&Rz, sizeof(Rz), 1, Temp);
  2066.  
  2067.         fread(&Tx, sizeof(Tx), 1, Temp);
  2068.         fread(&Ty, sizeof(Ty), 1, Temp);
  2069.         fread(&Tz, sizeof(Tz), 1, Temp);
  2070.  
  2071.         fread(&Rix, sizeof(double), 1, Temp);
  2072.         fread(&Riy, sizeof(double), 1, Temp);
  2073.         fread(&Riz, sizeof(double), 1, Temp);
  2074.  
  2075.         fread(&RxOffset, sizeof(RxOffset), 1, Temp);
  2076.         fread(&RyOffset, sizeof(RyOffset), 1, Temp);
  2077.         fread(&RzOffset, sizeof(RzOffset), 1, Temp);
  2078.  
  2079.         fread(&TxOffset, sizeof(TxOffset), 1, Temp);
  2080.         fread(&TyOffset, sizeof(TyOffset), 1, Temp);
  2081.         fread(&TzOffset, sizeof(TzOffset), 1, Temp);
  2082.  
  2083.         fread(&RiOffsetX, sizeof(double), 1, Temp);
  2084.         fread(&RiOffsetY, sizeof(double), 1, Temp);
  2085.         fread(&RiOffsetZ, sizeof(double), 1, Temp);
  2086.  
  2087.         fread(&sFx, sizeof(unsigned), 1, Temp);
  2088.         fread(&sFy, sizeof(unsigned), 1, Temp);
  2089.         fread(&sFz, sizeof(unsigned), 1, Temp);
  2090.  
  2091.         strcpy(Fx, "");
  2092.         strcpy(Fy, "");
  2093.         strcpy(Fz, "");
  2094.  
  2095.         fread(Fx, sFx, 1, Temp);
  2096.         fread(Fy, sFy, 1, Temp);
  2097.         fread(Fz, sFz, 1, Temp);
  2098.  
  2099.         fread(&Texture, sizeof(char), 1, Temp);
  2100.         fread(&Select, sizeof(char), 1, Temp);
  2101.  
  2102.         strcpy(Color, "");
  2103.         fread(&sColor, sizeof(unsigned), 1, Temp);
  2104.         fread(Color, sColor, 1, Temp);
  2105.  
  2106.         fread(&font1, sizeof(char), 1, Temp);
  2107.  
  2108.         strcpy(TextoS, "");
  2109.         fread(&sTextoS, sizeof(unsigned), 1, Temp);
  2110.         fread(TextoS, sTextoS, 1, Temp);
  2111.  
  2112.         fread(&Scale, sizeof(Scale), 1, Temp);
  2113.         fread(&LongPag, sizeof(LongPag), 1, Temp);
  2114.  
  2115.         PutsTranslate();
  2116.     }
  2117. }
  2118.  
  2119. void SetScale(void)
  2120. {
  2121.     printf ("Introduce tamaño de la letra o el objeto [%f] : ", ScaleF);
  2122.     gets(Buffer);
  2123.  
  2124.     if (Buffer[0])
  2125.     {
  2126.         Scale = atof(Buffer);
  2127.         ScaleF = Scale;
  2128.     }
  2129.     else
  2130.         Scale = ScaleF;
  2131. }
  2132.  
  2133. void SetAmbiente(void)
  2134. {
  2135.     char AmbName[255];
  2136.  
  2137.     printf("Quieres incluir un fichero con una camara o mas objetos.\n");
  2138.     printf("\n (1) Incluir el fichero.");
  2139.     printf("\n (2) Incluir el fichero y anular los objetos internos.");
  2140.     printf("\n (3) No incluir ningun fichero.");
  2141.     printf("\n (4) No incluir ningun fichero y anular objetos internos (inc).\n");
  2142.     printf("\nTu eligues [3]: ");
  2143.     Ambiente = getc(stdin);
  2144.  
  2145.     if (Ambiente == '\n')
  2146.         Ambiente = '3';
  2147.     else
  2148.         getc(stdin);
  2149.  
  2150.     if (RayT == '1')
  2151.         strcpy(AmbName, "Ambpov.inc");
  2152.     else
  2153.         strcpy(AmbName, "Ambpoly.inc");
  2154.  
  2155.     if (Ambiente ==  '1' || Ambiente == '2')
  2156.     {
  2157.         printf("Nombre del fichero a incluir [%s]: ", AmbName);
  2158.         gets(Buffer);
  2159.  
  2160.         if (Buffer[0])
  2161.             strcpy(IncludeName, Buffer);
  2162.         else
  2163.             strcpy(IncludeName, AmbName);
  2164.     }
  2165. }
  2166.  
  2167. void PutsStartUnion(void)
  2168. {
  2169.     if (RayT == '2')
  2170.             fprintf(out, "object {");
  2171.     else
  2172.             fprintf(out, "union {");
  2173. }
  2174.  
  2175. void PutsEndObject(void)
  2176. {
  2177.     if (RayT == '2')
  2178.         fprintf(out, "       +\n");
  2179. }
  2180.  
  2181. void PutsDefCamera(void)
  2182. {
  2183.     if (RayT == '1')
  2184.     {
  2185.         fprintf(out, "// Posicion de la camara\n");
  2186.         fprintf(out, "camera {\n");
  2187.         fprintf(out, "   location <%f, %f, %f>\n", CamX, CamY, CamPos);
  2188.         fprintf(out, "   direction <0.0, 0.0, %f>\n", Zoom);
  2189.         fprintf(out, "   up  <0.0, 1.0, 0.0>\n");
  2190.         fprintf(out, "   right <%s, 0.0, 0.0>\n", Aspect);
  2191.         fprintf(out, "   look_at <0, 0.0, 0.0 >\n");
  2192.         fprintf(out, "}\n\n");
  2193.  
  2194.         fprintf(out, "// Aqui van las fuentes de luz.\n");
  2195.         fprintf(out, "object {\n");
  2196.         fprintf(out, "        light_source { <3.0, 15.0, -20.0>\n");
  2197.         fprintf(out, "                       colour White\n");
  2198.         fprintf(out, "        }\n");
  2199.         fprintf(out, "}\n\n");
  2200.  
  2201.         fprintf(out, "object {\n");
  2202.         fprintf(out, "        light_source { <15.0, 10.0, -25.0>\n");
  2203.         fprintf(out, "                       colour White\n");
  2204.         fprintf(out, "        }\n");
  2205.         fprintf(out, "}\n\n");
  2206.     }
  2207.     else
  2208.     {
  2209.         fprintf (out, "viewpoint {\n");
  2210.         fprintf(out, "       from <PosCamX, PosCamY, PosCamZ>\n");
  2211.         fprintf(out, "       at <0,0,0>\n");
  2212.         fprintf(out, "       up <0,1,0>\n");
  2213.         fprintf(out, "       angle 45\n");
  2214.         fprintf(out, "       resolution 160, 120\n");
  2215.         fprintf(out, "       aspect %s\n", Aspect);
  2216.         fprintf(out, "}\n\n");
  2217.  
  2218.         fprintf(out, "light <1, 1, 1>, <0,0,-50>\n\n");
  2219.     }
  2220. }
  2221.